package com.ruoyi.wisdom.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wisdom.domain.IotStudentParent;
import com.ruoyi.wisdom.service.IIotStudentParentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 家长管理Controller
 * 
 * @author ruoyi
 * @date 2024-12-31
 */
@RestController
@RequestMapping("/wisdom/parent")
public class IotStudentParentController extends BaseController
{
    @Autowired
    private IIotStudentParentService iotStudentParentService;

    /**
     * 查询家长管理列表
     */
    @PreAuthorize("@ss.hasPermi('wisdom:parent:list')")
    @GetMapping("/list")
    public TableDataInfo list(IotStudentParent iotStudentParent)
    {
        startPage();
        List<IotStudentParent> list = iotStudentParentService.selectIotStudentParentList(iotStudentParent);
        return getDataTable(list);
    }

    /**
     * 导出家长管理列表
     */
    @PreAuthorize("@ss.hasPermi('wisdom:parent:export')")
    @Log(title = "家长管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IotStudentParent iotStudentParent)
    {
        List<IotStudentParent> list = iotStudentParentService.selectIotStudentParentList(iotStudentParent);
        ExcelUtil<IotStudentParent> util = new ExcelUtil<IotStudentParent>(IotStudentParent.class);
        util.exportExcel(response, list, "家长管理数据");
    }

    /**
     * 获取家长管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('wisdom:parent:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(iotStudentParentService.selectIotStudentParentById(id));
    }

    /**
     * 新增家长管理
     */
    @PreAuthorize("@ss.hasPermi('wisdom:parent:add')")
    @Log(title = "家长管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IotStudentParent iotStudentParent)
    {
        return toAjax(iotStudentParentService.insertIotStudentParent(iotStudentParent));
    }

    /**
     * 修改家长管理
     */
    @PreAuthorize("@ss.hasPermi('wisdom:parent:edit')")
    @Log(title = "家长管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IotStudentParent iotStudentParent)
    {
        return toAjax(iotStudentParentService.updateIotStudentParent(iotStudentParent));
    }

    /**
     * 删除家长管理
     */
    @PreAuthorize("@ss.hasPermi('wisdom:parent:remove')")
    @Log(title = "家长管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(iotStudentParentService.deleteIotStudentParentByIds(ids));
    }
}
